<%--
  Created by IntelliJ IDEA.
  User: yasser
  Date: 2016/8/9
  Time: 13:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>微销宝-登录</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/0.4.3/weui.min.css">
    <style type="text/css">
        .hd_my {
            background-color: red;
            text-align: center;
            color: #fff;
        }

        .bottom_my {
            background-color: red;
            text-align: center;
            color: #fff;
            height: 35px;
            line-height: 35px;
            font-weight: bold;
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
        }
    </style>
</head>
<body>
<div class="hd hd_my">
    <h1 class="page_title">微销宝</h1>
</div>
<div class="weui_cells_title" style="text-align: center; padding: 5px 0;  ">
    <h1>登录</h1>
</div>

<div class="weui_cells weui_cells_form">
    <div class="weui_cell">
        <div class="weui_cell_hd"><label class="weui_label">手机号码</label></div>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" id="phone" name="phone" type="text" placeholder="请输入手机号" maxlength="11"/>
        </div>
    </div>
    <div class="weui_cell">
        <div class="weui_cell_hd"><label class="weui_label">登录密码</label></div>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" id="password" type="password" placeholder="请输入登录密码" maxlength="16"/>
        </div>
    </div>
</div>
<div class="weui_btn_area">
    <a class="weui_btn weui_btn_primary" href="javascript:" id="btn_login">登录</a>
</div>

<!--登录结果的 toast-->
<div id="toast" style="display: none;">
    <div class="weui_mask_transparent"></div>
    <div class="weui_toast">
        <i class="weui_icon_toast"></i>
        <p class="weui_toast_content">已完成</p>
    </div>
</div>
<!--登录结果的 toast-->

</body>
<!-- body 最后
<script src="${pageContext.request.contextPath}/res/js/zepto.min.js"></script>
-->
<script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/res/js/Validator.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    $(function () {
        // 为按钮绑定点击事件
        $("#btn_login").on("click", function () {
            var phone = $("#phone").val();
            var password = $("#password").val();
            if(Validator.phone(phone) && password!=""){
                $.ajax({
                    url:"${pageContext.request.contextPath}/login/submit",
                    data:{"phone":phone, "password":password},
                    type:"post",
                    success:function(result){
                        $("#toast .weui_toast_content").text(result.msg);
                        $('#toast').show();
                        setTimeout(function () {
                            $('#toast').hide();
                            if(result.status == 1){
                                window.location.href = "/index";
                            }
                        }, 2000);
                    }
                })
            }
        })
    })

</script>
</html>